import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';
import { AfterInsert } from 'typeorm/decorator/listeners/AfterInsert';

/**
 * 设备请求日志
 */
@Entity('device_request_log')
export class DeviceRequestLogEntity extends BaseEntity {
  @Index()
  @Column({ comment: '设备ID' })
  deviceId: number;

  @Index()
  @Column({ comment: '请求方法', dict: ['GET', 'POST', 'PUT', 'DELETE'] })
  requestMethod: number;

  @Column({ comment: '请求参数', type: 'text', nullable: true })
  requestParams: string;

  @Column({ comment: '响应结果', type: 'text', nullable: true })
  responseResult: string;

  @Index()
  @Column({ comment: '状态码' })
  statusCode: number;

  @Column({ comment: '处理耗时(ms)' })
  processTime: number;

  @Index()
  @Column({ comment: '请求时间', type: 'datetime' })
  requestTime: Date;
}
